//http://localhost:8080
//http://manage.bandtechs.com
//'http://localhost:8080/xconsole'

import codeMsg from "./codeMsg";
import {
  version_num
} from "../../version.js";
class util {
  constructor() {
    // this.baseUrl =
    //   process.env.NODE_ENV == "development" ?
    //   "http://10.168.1.172:8989/xconsole" :
    //   "/xconsole";
    this.baseUrl = "/api/v1";
    this.platform = "MR";
    this.codeMsg = codeMsg;
    this.version = version_num;
  }
  getTime(time) {
    var str = "";
    var time = new Date(time);
    var timer = time.toLocaleDateString().split("/");
    timer[1] <= 9 ? (timer[1] = "0" + timer[1]) : "";
    timer[2] <= 9 ? (timer[2] = "0" + timer[2]) : "";
    var hours = time.getHours() > 9 ? time.getHours() : "0" + time.getHours();
    var minutes =
      time.getMinutes() > 9 ? time.getMinutes() : "0" + time.getMinutes();
    var seconds =
      time.getSeconds() > 9 ? time.getSeconds() : "0" + time.getSeconds();
    str = timer.join("-") + " " + hours + ":" + minutes + ":" + seconds;
    return str;
  }
  setTitle(title) {
    title = title ? title : "警训";
    window.document.title = title;
  }
  to(device) {
    let max = device.MaxAccessoriesNumber || 4;
    let _accessories = [];
    for (let i = 0; i < max; i++) {
      _accessories.push({
        ID: i,
        Bindings: null,
        position: i,
        State: ""
      });
    }
    device.Accessories = device.Accessories || [];
    for (let j = 0; j < device.Accessories.length; j++) {
      let bindInfo = device.Accessories[j].Bindings.find(
        (item) => item.Type == "Device"
      );
      let pos = bindInfo.Position;
      _accessories[pos] = device.Accessories[j];
    }
    return _accessories;
  }
}

util.prototype.tableColumns = {
  trainDevice: {
    group: [{
      title: "编号",
      key: "index",
      align: "center",
      width: 70,
      render: (h, params) => {
        return h("strong", params.row.index);
      },
    }, ],
    touXian: [],
    waiShe: [],
  },
};
export default new util();